﻿<!--#Include File = "CustomTemplate.asp" -->

<%
	Call  PageController.RenderPage()
	Public Function Page_Configure()
		PageController.PageTitle = "List request publish"
		PageController.AuthorizedRoles =  Array("publisher")
		pageController.RequiresAuthentication  = True
		PageController.PageCSSFiles = "main.css" 	
		
	End function
%>
<%Public Function Page_RenderForm()%>
	<H2>List request publish</H2>
	
	<%	Page.Execute %>
	<Span Class="Caption">List request<HR></Span>	

	<%gdRequest%>	
	
	<hr>
	
<%End Function%>


<%  'This would normaly go in a another page, but for the sake of simplicity and to minimize the number of pages
    'I'm including code behind stuff here...	
	Dim gdRequest
		
	Public Function Page_Init()
		
		Set gdRequest = New_ServerDataGrid("gdRequest")		
		Page.AutoResetScrollPosition = True
	End Function

	Public Function Page_Controls_Init()						
	End Function
	
	Public Function Page_PreRender()						
		Call ShowRecords()
	End Function
	
Public Sub SetTemplate(obj)		 
	obj.AlternatingItemStyle = "background-color:#dddddd;font-size:8pt;border:1px solid black" 
	obj.ItemStyle = "font-size:8pt;border:1px solid black"
	obj.Control.Style = "width:100%;border-collapse:collapse;"
	obj.HeaderStyle = "font-weight:bold;color:white;background-color:#4682b4;font-size:10pt;font-family:tahoma;border:1px solid black"
	obj.BorderWidth = 1
	obj.BorderColor = "Black"
	obj.GenerateColumns() 'Just so it generates most of them :-)
	obj.CreateColumns Array("title" , "userrequest","requestcomment", "requesttime", "userapproval", "approvalcomment", "approvaltime","status","") , Array("Content Title", "User Request","Request","Request Time","User Approval","Approval comment", "Approval Time","Status", "Action")
	obj.AutoGenerateColumns = False  'Now lets not have it generate the columns again during render!
	
	
	obj.Columns(7).ColumnType = 3    'Modify the column settings we need.	
	obj.Columns(7).CellRenderFunctionName = "RenderStatusColumn"
	
	
	obj.Columns(8).ColumnType = 3    'Modify the column settings we need.
	obj.Columns(8).HeaderText = "Actions"
	obj.Columns(8).HorizonalAlign = "center"
	obj.Columns(8).CellRenderFunctionName = "RenderActionColumn"
	
	
	obj.Pager.ProgressStyle = "font-size:8pt"
	obj.Pager.PrevNextStyle = "font-size:8pt"
	obj.Pager.PagerStyle    = "font-size:8pt"
	obj.AllowPaging = True
	
	
End Sub
Public Function RenderStatusColumn(ds)
		if ds("status").Value = 10 then
			Response.Write("Request Publish")
		elseif ds("status").Value = 20 then
			Response.Write("Allowed Publish")
		elseif ds("status").Value = 30 then
			Response.Write("Denied Publish")
		end if
End Function

Public Function RenderActionColumn(ds)
		
		If ds("status") =10  Then
			Response.Write("<a href=Approval.asp?id="&ds("id").Value&">Approval</a>")
	
			'Response.Write "<A " & Page.GetEventScript("HREF","Page","ActiveUser",ds("id").Value,"") & " Class='ActionLink'>Active</a>"
			
		End If
End Function

Public Function ShowRecords()
	Dim sSQL
	sSQL = "SELECT c.title, a.*, u.username FROM approval as a inner join content as c on a.contentid = c.id " & _
		"inner join [user] as u on u.id =a.userrequest"
	
	Set gdRequest.DataSource = GetRecordset(sSQL)

	SetTemplate gdRequest

End Function


		
	
%>